package com.bluemoon.model.test.mock;

import cn.com.bluemoon.daps.model.DapsModelApplication;
import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

/**
 * @author Jarod.Kong
 * @date 2021/2/23 13:42
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = DapsModelApplication.class,
        webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class MockControllerTest2 {
    @Autowired
    private TestRestTemplate restTemplate;

    @Test
    public void getHello2() {
        MultiValueMap multiValueMap = new LinkedMultiValueMap();
        multiValueMap.add("id", "1");
        String response = restTemplate.postForObject("/api/hello/say", multiValueMap, String.class);
        Assertions.assertThat(response).contains("hello");
    }
}
